package com.example.imtoken.modules.main.browse

import android.view.ViewGroup
import android.widget.LinearLayout
import com.blankj.utilcode.util.BarUtils
import com.example.imtoken.R
import com.example.imtoken.core.base.BaseFragment
import com.example.imtoken.databinding.BrowseFragmentBinding
import com.just.agentweb.AgentWeb

/**
 * 浏览
 */
open class BrowseFragment :
    BaseFragment<BrowseViewModel, BrowseFragmentBinding>(BrowseViewModel::class.java) {

    private lateinit var mAgentWeb: AgentWeb

    override fun initLayoutId(): Int {
        return R.layout.browse_fragment
    }

    override fun init() {
        BarUtils.transparentStatusBar(requireActivity())
        initView()
    }

    private fun initView() {
        mAgentWeb = AgentWeb.with(this)
            .setAgentWebParent(
                dataBinding.root as LinearLayout,
                -1,
                LinearLayout.LayoutParams(
                    ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT
                )
            )
            //设置进度条颜色与高度，-1为默认值，高度为2，单位为dp。
            .useDefaultIndicator(-1, 3)
            .createAgentWeb()
            .ready()
            .go("http://app.k3zx.cn/#/walletUi/Browse")
    }

    override fun onPause() {
        mAgentWeb.webLifeCycle.onPause()
        super.onPause()
    }

    override fun onResume() {
        mAgentWeb.webLifeCycle.onResume()
        super.onResume()
    }

    override fun onDestroy() {
        mAgentWeb.webLifeCycle.onDestroy()
        super.onDestroy()
    }

}